package com.aaa.generics.demo02;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author C-Q
 * @version 1.1.0
 * @Description: 使用泛型解决数据类型安全问题
 * @date 2022/10/25
 */
public class Test01 {
    public static void main(String[] args) {
        //使用泛型解决数据类型安全问题
        //字符串类型
        Generics<String> generics = new Generics<>("hi","hello");
        String x = generics.getX();
        String y = generics.getY();
        //整型
        Generics<Integer> generics1 = new Generics<>(66,88);
        Integer x1 = generics1.getX();
        Integer y1 = generics1.getY();
        System.out.println(generics+"=====generics"+generics1+"=====generics1");

        Gen<Integer,String,Double> gen = new Gen<>();
        gen.a=25;
        gen.b="Hi";
        gen.c=34.6;
        System.out.println(gen+"====gen");
    }
}
/**
 * 指定泛型时可以使用多个标识
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
class Gen<A,B,C>{
    public A a;
    public B b;
    public C c;
        }